package com.yixing.demo.controller;

import com.yixing.demo.model.HistoryMessage;
import com.yixing.demo.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

@Slf4j
@RequestMapping("/message")
@RestController
public class MessageController {
    @Resource
    MessageService messageService;
    @RequestMapping("/getmessage")
    public Object getmessage(int sessionId) {
        List<HistoryMessage> historyMessages = messageService.getHistoryMessageBySessionId(sessionId);
        Collections.reverse(historyMessages);
        return historyMessages;
    }
}
